﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess.Classes;

namespace Webmau.Admin
{
    public partial class CapNhatPhongTro : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            List<DiaDiem1> list = DiaDiem1.LayDanhSach();
            ddlDiaDiem.DataSource = list;
            ddlDiaDiem.DataTextField = "TenDiaDiem";
            ddlDiaDiem.DataValueField = "ID";
            ddlDiaDiem.DataBind();

            string id = Request.QueryString["cid"].ToString();
            PhongTro1 phong = PhongTro1.Single(id);
            txtTen.Text = phong.Ten;
            txtThongTin.Text = phong.ThongTin;
            txtGiaPhong.Text = phong.GiaTien.ToString();
            txtHinh.Text = phong.HinhChinh;
        }
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            string id = Request.QueryString["cid"].ToString();
            PhongTro1 phong = PhongTro1.Single(id);
            phong.ID = Convert.ToInt32(ddlDiaDiem.SelectedValue.ToString());
            phong.Ten = txtTen.Text;
            phong.ThongTin = txtThongTin.Text;
            phong.HinhChinh = txtHinh.Text;
            phong.HinhDaiDien = txtHinh.Text;
            if (chkTinhTrang.Checked == true)
            {
                phong.TinhTrang = Convert.ToBoolean("True".ToString());
            }
            if (chkTinhTrang.Checked == false)
            {
                phong.TinhTrang = Convert.ToBoolean("False".ToString());
            }
            PhongTro1.CapNhat(phong);
        }
    }
}